package com.rockgle.reader;

import java.util.ArrayList;

public class SortedEntryList extends ArrayList<Entry> {
	private static final long serialVersionUID = -4305946150935514668L;
	
	public synchronized void insertSorted(Entry entry){
		if (entry!=null && !this.contains(entry)){
			if (this.size()==0){
				this.add(entry);
			}else{
				int i=0;
				while(i<this.size() && 
						this.get(i).getPublishedRFC3339().compareTo(entry.getPublishedRFC3339())>0){
					i++;
				}

				this.add(i, entry);
			}
		}
	}

}
